﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace TileMapEditor
{
    public enum RuleCheckType
    {
        [EnumDescription("无")]
        None = 0,
        [EnumDescription("计数器")]
        CountTime = 1,
        [EnumDescription("遗物")]
        Relic = 2,
        [EnumDescription("英雄")]
        Hero = 3,
        [EnumDescription("地图是否存在物件")]
        HasObj = 6
            //4 判断阵亡英雄数 5 判断通过关卡ID，暂时是迷宫用
    }

    public enum CompareType
    {
        [EnumDescription("小于")]
        LessThan = 1,
        [EnumDescription("等于")]
        Equal = 2,
        [EnumDescription("大于")]
        MoreThan = 3,
    }

    public enum HasType
    {
        [EnumDescription("没有")]
        None = 0,
        [EnumDescription("拥有")]
        Has = 1,
    }

    [CreateAssetMenu(fileName = "New CheckRule", menuName = "六边形地图编辑/条件检测", order = 4)]
    [System.Serializable]
    public class TriggerRuleCheck :ScriptableObject
    {
        [Header("条件检测器")]
        public int id;
        [SerializeField]
        public List<CheckRule> rules = new List<CheckRule>();
        [SerializeField]
        public List<Effect> effect;//校验通过时执行的效果
        [HideInInspector]
        public bool needServerCheck = false;

        public static string[] RuleCheckTypeNames = EnumParser.GetEnumDescriptions(typeof(RuleCheckType));
        public static int[] RuleCheckTypes = EnumParser.GetEnumValues(typeof(RuleCheckType));
    }

    [System.Serializable]
    public class CheckRule
    {
        [Header("检测条件")]
        public int type;//RuleCheckType
        public int targetId;//目标ID 按类型：1 计数器 2 遗物 3 英雄
        public int targetValue;
        public int compareType = (int)CompareType.Equal;// 0 等于 1 小于 2 大于

        public static string[] CompareTypeNames = EnumParser.GetEnumDescriptions(typeof(CompareType));
        public static int[] CompareTypes = EnumParser.GetEnumValues(typeof(CompareType));
        public static string[] HasTypeNames = EnumParser.GetEnumDescriptions(typeof(HasType));
        public static int[] HasTypes = EnumParser.GetEnumValues(typeof(HasType));
    }
}